package hnlg.com.cn.purviewmanage.rolemanage.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hnlg.com.cn.model.RoleVO;
import hnlg.com.cn.purviewmanage.rolemanage.mapper.RoleMapper;

@Service("RoleService")
@Transactional(value="txManager",rollbackFor=Exception.class)
public class IRoleServiceImpl implements IRoleService {

	@Autowired RoleMapper obj;
	@Override
	public List<RoleVO> queryList(RoleVO vo) throws Exception {
		
		return obj.queryList(vo);
	}

	@Override
	public boolean addRole(RoleVO vo) throws Exception {
		
		return obj.addRole(vo);
	}

	@Override
	public boolean updateRole(RoleVO vo) throws Exception {
	
		return obj.updateRole(vo);
	}

	@Override
	public boolean deleteRole(String roleid) throws Exception {
		
		return obj.deleteRole(roleid);
	}

	@Override
	public boolean roleaddModule(String roleid, String[] moduleid) throws Exception {
		boolean flag=true;
		try{
			obj.deleteRoleModule(roleid);
			obj.roleaddModule(roleid, moduleid);
			
		}catch(Exception e){
			flag=false;
			throw e;//有异常要抛出来让spring容器去捕捉
		}
		return flag;
	}

	@Override
	public List queryModuleIdList(String roleid) throws Exception {
		return obj.queryModuleIdList(roleid);
	}

	@Override
	public boolean deleteRoleModule(String roleid) throws Exception {
		return obj.deleteRoleModule(roleid);
	}

}
